home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple WWDC 1996
/
WWDC96_1996 (CD).toast
/
Technology Materials
/
MacOS 8 Resources
/
Developer Tools
/
Mac OS 8 Interfaces & Libraries
/
Interfaces
/
CIncludes
/
Unicode.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-01
|
14KB
|
355 lines
/*
File: Unicode.h
Contains: Unicode Interfaces.
Version: Technology: System 7.1 through System 8
Release: Universal Interfaces 3.0d3 on Copland DR1
Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
Bugs?: If you find a problem with this file, send the file and version
information (from above) and the problem description to:
Internet: apple.bugs@applelink.apple.com
AppleLink: APPLE.BUGS
*/
#ifndef __UNICODE__
#define __UNICODE__
#ifndef __TYPES__
#include <Types.h>
#endif
#ifndef __TEXTCOMMON__
#include <TextCommon.h>
#endif
#ifndef __MIXEDMODE__
#include <MixedMode.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT_SUPPORTED
#pragma import on
#endif
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=mac68k
#endif
#if 0
/*
The following 7 typedefs are required for seeds until they get
moved to a future version of Types.[hp] in a future ETO release.
Also note that seeds should include a copy of the new TextCommon.[hp].
*/
typedef UInt8 *BytePtr;
typedef UInt32 ByteCount;
typedef UInt32 ItemCount;
typedef UInt32 OptionBits;
typedef short RegionCode;
typedef UInt32 ByteOffset;
typedef const void *ConstLogicalAddress;
/*
The following typedefs are required for seeds until they get
moved to a future version of Errors.[hp] in a future ETO release.
Unicode Converter Error Codes
*/
enum {
unicodeChecksumErr = -8769,
unicodeNoTableErr = -8768,
unicodeVariantErr = -8767,
unicodeFallbacksErr = -8766,
unicodePartConvertErr = -8765,
unicodeBufErr = -8764,
unicodeCharErr = -8763,
unicodeElementErr = -8762,
unicodeNotFoundErr = -8761,
unicodeTableFormatErr = -8760,
unicodeDirectionErr = -8759,
unicodeContextualErr = -8758,
unicodeTextEncodingDataErr = -8757
};
#endif
#if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
/* Unicode Converter Gestalt Constants: (****these belong in Gestalt.i****) */
enum {
gestaltUnicodeAttr = 'unic',
gestaltUnicodeConverterPresent = 0,
gestaltUnicodeConverterMask = 1L << gestaltUnicodeConverterPresent
};
/* Basic types for Unicode characters and strings: */
typedef UniChar *UniCharArrayPtr;
typedef const UniChar *ConstUniCharArrayPtr;
/* Unicode conversion contexts: */
typedef struct OpaqueTextToUnicodeInfo* TextToUnicodeInfo;
typedef struct OpaqueUnicodeToTextInfo* UnicodeToTextInfo;
typedef struct OpaqueUnicodeToTextRunInfo* UnicodeToTextRunInfo;
typedef const TextToUnicodeInfo ConstTextToUnicodeInfo;
typedef const UnicodeToTextInfo ConstUnicodeToTextInfo;
/* UnicodeMapVersion type & values */
typedef SInt32 UnicodeMapVersion;
enum {
kUnicodeUseLatestMapping = -1
};
/* Types used in conversion */
struct UnicodeMapping {
TextEncoding unicodeEncoding;
TextEncoding otherEncoding;
UnicodeMapVersion mappingVersion;
};
typedef struct UnicodeMapping UnicodeMapping;
typedef UnicodeMapping *UnicodeMappingPtr;
typedef const UnicodeMapping *ConstUnicodeMappingPtr;
struct TextEncodingRun {
ByteOffset offset;
TextEncoding textEncoding;
};
typedef struct TextEncodingRun TextEncodingRun;
/* Control flags for ConvertUnicodeToText and ConvertTextToUnicode */
enum {
kUnicodeUseFallbacksBit = 0,
kUnicodeKeepInfoBit = 1,
kUnicodeDirectionalityBits = 2,
kUnicodeVerticalFormBit = 4,
kUnicodeLooseMappingsBit = 5,
kUnicodeStringUnterminatedBit = 6,
kUnicodeTextRunBit = 7,
kUnicodeKeepSameEncodingBit = 8
};
enum {
kUnicodeUseFallbacksMask = 1L << kUnicodeUseFallbacksBit,
kUnicodeKeepInfoMask = 1L << kUnicodeKeepInfoBit,
kUnicodeDirectionalityMask = 3L << kUnicodeDirectionalityBits,
kUnicodeVerticalFormMask = 1L << kUnicodeVerticalFormBit,
kUnicodeLooseMappingsMask = 1L << kUnicodeLooseMappingsBit,
kUnicodeStringUnterminatedMask = 1L << kUnicodeStringUnterminatedBit,
kUnicodeTextRunMask = 1L << kUnicodeTextRunBit,
kUnicodeKeepSameEncodingMask = 1L << kUnicodeKeepSameEncodingBit
};
/* Values for kUnicodeDirectionality field */
enum {
kUnicodeDefaultDirection = 0,
kUnicodeLeftToRight = 1,
kUnicodeRightToLeft = 2
};
/* Control flags for TruncateForUnicodeToText: */
enum {
kUnicodeTextElementSafeBit = 0,
kUnicodeRestartSafeBit = 1
};
enum {
kUnicodeTextElementSafeMask = 1L << kUnicodeTextElementSafeBit,
kUnicodeRestartSafeMask = 1L << kUnicodeRestartSafeBit
};
/* Filter bits for QueryUnicodeMappings filter field: */
enum {
kUnicodeMatchUnicodeBaseBit = 0,
kUnicodeMatchUnicodeVariantBit = 1,
kUnicodeMatchUnicodeFormatBit = 2,
kUnicodeMatchOtherBaseBit = 3,
kUnicodeMatchOtherVariantBit = 4,
kUnicodeMatchOtherFormatBit = 5
};
enum {
kUnicodeMatchUnicodeBaseMask = 1L << kUnicodeMatchUnicodeBaseBit,
kUnicodeMatchUnicodeVariantMask = 1L << kUnicodeMatchUnicodeVariantBit,
kUnicodeMatchUnicodeFormatMask = 1L << kUnicodeMatchUnicodeFormatBit,
kUnicodeMatchOtherBaseMask = 1L << kUnicodeMatchOtherBaseBit,
kUnicodeMatchOtherVariantMask = 1L << kUnicodeMatchOtherVariantBit,
kUnicodeMatchOtherFormatMask = 1L << kUnicodeMatchOtherFormatBit
};
/* Control flags for SetFallbackUnicodeToText */
enum {
kUnicodeFallbackSequencingBits = 0
};
enum {
kUnicodeFallbackSequencingMask = 3L << kUnicodeFallbackSequencingBits
};
/* values for kUnicodeFallbackSequencing field */
enum {
kUnicodeFallbackDefaultOnly = 0L,
kUnicodeFallbackCustomOnly = 1L,
kUnicodeFallbackDefaultFirst = 2L,
kUnicodeFallbackCustomFirst = 3L
};
#endif
#if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
/* Caller-supplied entry point to a fallback handler */
typedef pascal OSStatus (*UnicodeToTextFallbackProcPtr)(UniChar *srcUniStr, ByteCount srcUniStrLen, ByteCount *srcConvLen, BytePtr destStr, ByteCount destStrLen, ByteCount *destConvLen, LogicalAddress contextPtr, ConstUnicodeMappingPtr unicodeMappingPtr);
#if GENERATINGCFM
typedef UniversalProcPtr UnicodeToTextFallbackUPP;
#else
typedef UnicodeToTextFallbackProcPtr UnicodeToTextFallbackUPP;
#endif
enum {
uppUnicodeToTextFallbackProcInfo = kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(OSStatus)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(UniChar *)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ByteCount)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(ByteCount *)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(BytePtr)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(ByteCount)))
| STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(ByteCount *)))
| STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(LogicalAddress)))
| STACK_ROUTINE_PARAMETER(8, SIZE_CODE(sizeof(ConstUnicodeMappingPtr)))
};
#if GENERATINGCFM
#define NewUnicodeToTextFallbackProc(userRoutine) \
(UnicodeToTextFallbackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUnicodeToTextFallbackProcInfo, GetCurrentArchitecture())
#else
#define NewUnicodeToTextFallbackProc(userRoutine) \
((UnicodeToTextFallbackUPP) (userRoutine))
#endif
#if GENERATINGCFM
#define CallUnicodeToTextFallbackProc(userRoutine, srcUniStr, srcUniStrLen, srcConvLen, destStr, destStrLen, destConvLen, contextPtr, unicodeMappingPtr) \
CallUniversalProc((UniversalProcPtr)(userRoutine), uppUnicodeToTextFallbackProcInfo, (srcUniStr), (srcUniStrLen), (srcConvLen), (destStr), (destStrLen), (destConvLen), (contextPtr), (unicodeMappingPtr))
#else
#define CallUnicodeToTextFallbackProc(userRoutine, srcUniStr, srcUniStrLen, srcConvLen, destStr, destStrLen, destConvLen, contextPtr, unicodeMappingPtr) \
(*(userRoutine))((srcUniStr), (srcUniStrLen), (srcConvLen), (destStr), (destStrLen), (destConvLen), (contextPtr), (unicodeMappingPtr))
#endif
#endif
#if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
typedef pascal OSStatus (*UnicodeToTextFallbackPreemptiveProcPtr)(UniChar *srcUniStr, ByteCount srcUniStrLen, ByteCount *srcConvLen, BytePtr destStr, ByteCount destStrLen, ByteCount *destConvLen, LogicalAddress contextPtr, ConstUnicodeMappingPtr unicodeMappingPtr);
/* Function prototypes */
/*
The following are in TextCommon.i:
CreateTextEncoding, GetTextEncodingBase, GetTextEncodingVariant, GetTextEncodingFormat
*/
/* Create a new TextToUnicodeInfo structure. */
extern pascal OSStatus CreateTextToUnicodeInfo(ConstUnicodeMappingPtr UnicodeMapping, TextToUnicodeInfo *textToUnicodeInfo)
THREEWORDINLINE(0x303C, 0x0401, 0xABCE);
/* Create a new UnicodeToTextInfo structure. */
extern pascal OSStatus CreateUnicodeToTextInfo(ConstUnicodeMappingPtr UnicodeMapping, UnicodeToTextInfo *unicodeToTextInfo)
THREEWORDINLINE(0x303C, 0x040C, 0xABCE);
extern pascal OSStatus CreateUnicodeToTextRunInfo(ItemCount numberOfMappings, ConstUnicodeMappingPtr UnicodeMapping, UnicodeToTextRunInfo *unicodeToTextInfo)
THREEWORDINLINE(0x303C, 0x0612, 0xABCE);
/* Dispose of a TextToUnicodeInfo structure. */
extern pascal OSStatus DisposeTextToUnicodeInfo(TextToUnicodeInfo *textToUnicodeInfo)
THREEWORDINLINE(0x303C, 0x0202, 0xABCE);
/* Dispose of a UnicodeToTextInfo structure. */
extern pascal OSStatus DisposeUnicodeToTextInfo(UnicodeToTextInfo *unicodeToTextInfo)
THREEWORDINLINE(0x303C, 0x020D, 0xABCE);
extern pascal OSStatus DisposeUnicodeToTextRunInfo(UnicodeToTextRunInfo *unicodeToTextInfo)
THREEWORDINLINE(0x303C, 0x0213, 0xABCE);
/* Convert a string to Unicode. */
extern pascal OSStatus ConvertTextToUnicode(TextToUnicodeInfo textToUnicodeInfo, ByteCount sourceLen, ConstLogicalAddress sourceStr, OptionBits controlFlags, ItemCount offsetCount, ByteOffset *offsetArray, ByteCount bufLen, ByteCount *sourceRead, ByteCount *unicodeLen, UniCharArrayPtr unicodeStr)
THREEWORDINLINE(0x303C, 0x1404, 0xABCE);
/* Convert a string from Unicode. */
extern pascal OSStatus ConvertUnicodeToText(UnicodeToTextInfo unicodeToTextInfo, ByteCount unicodeLen, ConstUniCharArrayPtr unicodeStr, OptionBits controlFlags, ItemCount offsetCount, ByteOffset *offsetArray, ByteCount bufLen, ByteCount *inputRead, ByteCount *outputLen, LogicalAddress outputStr)
THREEWORDINLINE(0x303C, 0x1403, 0xABCE);
extern pascal OSStatus ConvertUnicodeToTextRun(UnicodeToTextRunInfo unicodeToTextInfo, ByteCount unicodeLen, ConstUniCharArrayPtr unicodeStr, OptionBits controlFlags, ItemCount offsetCount, ByteOffset *offsetArray, ByteCount bufLen, ByteCount *inputRead, ByteCount *outputLen, LogicalAddress outputStr, ItemCount encodingRunBufLen, ItemCount *encodingRunOutLen, TextEncodingRun *encodingRuns)
THREEWORDINLINE(0x303C, 0x1A14, 0xABCE);
/* Truncate a multibyte string at a safe place. */
extern pascal OSStatus TruncateForTextToUnicode(ConstTextToUnicodeInfo textToUnicodeInfo, ByteCount sourceLen, ConstLogicalAddress sourceStr, ByteCount maxLen, ByteCount *truncatedLen)
THREEWORDINLINE(0x303C, 0x0A06, 0xABCE);
/* Truncate a Unicode string at a safe place. */
extern pascal OSStatus TruncateForUnicodeToText(ConstUnicodeToTextInfo unicodeToTextInfo, ByteCount sourceLen, ConstUniCharArrayPtr sourceStr, OptionBits controlFlags, ByteCount maxLen, ByteCount *truncatedLen)
THREEWORDINLINE(0x303C, 0x0C05, 0xABCE);
/* Convert a Pascal string to Unicode. */
extern pascal OSStatus ConvertPStringToUnicode(TextToUnicodeInfo textToUnicodeInfo, ConstStr255Param pascalStr, ByteCount bufLen, ByteCount *unicodeLen, UniCharArrayPtr unicodeStr)
THREEWORDINLINE(0x303C, 0x0A08, 0xABCE);
/* Convert a Unicode string to Pascal. */
extern pascal OSStatus ConvertUnicodeToPString(UnicodeToTextInfo unicodeToTextInfo, ByteCount unicodeLen, ConstUniCharArrayPtr unicodeStr, Str255 pascalStr)
THREEWORDINLINE(0x303C, 0x0807, 0xABCE);
/* Get a list of the available conversion mappings. */
extern pascal OSStatus QueryUnicodeMappings(OptionBits filter, ConstUnicodeMappingPtr findMapping, ItemCount maxCount, ItemCount *actualCount, UnicodeMappingPtr returnedMappings)
THREEWORDINLINE(0x303C, 0x0A09, 0xABCE);
/* Get the name of a TextEncodingBase table. */
extern pascal OSStatus GetTextEncodingBaseName(ConstUnicodeMappingPtr UnicodeMapping, LangCode languageID, ByteCount bufLen, ByteCount *nameLength, UniCharArrayPtr mappingName)
THREEWORDINLINE(0x303C, 0x090A, 0xABCE);
/* Change the TextToUnicodeInfo to another mapping. */
extern pascal OSStatus ChangeTextToUnicodeInfo(TextToUnicodeInfo textToUnicodeInfo, ConstUnicodeMappingPtr UnicodeMapping)
THREEWORDINLINE(0x303C, 0x040B, 0xABCE);
/* Change the UnicodeToTextInfo to another mapping. */
extern pascal OSStatus ChangeUnicodeToTextInfo(UnicodeToTextInfo unicodeToTextInfo, ConstUnicodeMappingPtr UnicodeMapping)
THREEWORDINLINE(0x303C, 0x040E, 0xABCE);
#endif
#if FOR_SYSTEM8_PREEMPTIVE
/* Setup the fallback handler for converting Unicode To Text. */
extern pascal OSStatus SetFallbackUnicodeToTextPreemptive(UnicodeToTextInfo unicodeToTextInfo, UnicodeToTextFallbackPreemptiveProcPtr fallback, OptionBits controlFlags, LogicalAddress infoPtr);
extern pascal OSStatus SetFallbackUnicodeToTextRunPreemptive(UnicodeToTextRunInfo unicodeToTextRunInfo, UnicodeToTextFallbackPreemptiveProcPtr fallback, OptionBits controlFlags, LogicalAddress infoPtr);
#endif
#if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
/* Setup the fallback handler for converting Unicode To Text. */
extern pascal OSStatus SetFallbackUnicodeToText(UnicodeToTextInfo unicodeToTextInfo, UnicodeToTextFallbackUPP fallback, OptionBits controlFlags, LogicalAddress infoPtr)
THREEWORDINLINE(0x303C, 0x080F, 0xABCE);
extern pascal OSStatus SetFallbackUnicodeToTextRun(UnicodeToTextRunInfo unicodeToTextRunInfo, UnicodeToTextFallbackUPP fallback, OptionBits controlFlags, LogicalAddress infoPtr)
THREEWORDINLINE(0x303C, 0x0819, 0xABCE);
/*
The following are in TextCommon.i:
UpgradeScriptInfoToTextEncoding, RevertTextEncodingToScriptInfo
*/
#endif
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset
#endif
#if PRAGMA_IMPORT_SUPPORTED
#pragma import off
#endif
#ifdef __cplusplus
}
#endif
#endif /* __UNICODE__ */